package com.burst.reptile.modular.zp.service.impl;

import com.burst.reptile.common.utils.ToolUtil;
import com.burst.reptile.modular.zp.entity.ZpHistory;
import com.burst.reptile.modular.zp.mapper.ZpHistoryMapper;
import com.burst.reptile.modular.zp.service.IZpHistoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 浏览历史 服务实现类
 * </p>
 *
 * @author wujin
 * @since 2020-08-25
 */
@Service
public class ZpHistoryServiceImpl extends ServiceImpl<ZpHistoryMapper, ZpHistory> implements IZpHistoryService {

	@Override
	public Page<ZpHistory> pageList(Page<ZpHistory> page, ZpHistory history) {
		Long userId = history.getUserId();
		QueryWrapper<ZpHistory> queryWrapper = new QueryWrapper<>();
		if(ToolUtil.isNotEmpty(userId)) {
			queryWrapper.eq("user_id", userId);
		}
		queryWrapper.orderByDesc("create_time");
		return this.page(page, queryWrapper);
	}

}
